<!--内部验收-->
<template>
  <t-collapse title="项目验收信息">
    <TForm ref="enteringForm" :form="formData" :form-options="formOptions" :rules="rules" :yanfa="getYanFa" :serviceShow="getShowThree" :firstAcceptTime="firstAcceptTime"/>
    <div v-if="!(getShowOneNew&&this.newPrjDetail.buildModes==='27')">
      <p ref="myTitle" v-if="!isReplace" style="color: red">内部验收通过后即可发起外部验收,但交维时应以资源确认为准;交维之前的维护工作应由项目经理负责,资源确认之后维护管理及客户服务职责转交维护部.</p>
    </div>
    <accButton :prj-id="prjId" :btn-list="btnOptions" v-if="!(getShowOneNew&&this.newPrjDetail.buildModes==='27'||getShowThree)"/>
  </t-collapse>
</template>
<script>
import TForm from '../form/index.vue'
import accButton from '@/views/acceptance/components/accButton.vue'
import { Mixins } from '@/views/acceptance/components/minix'
import {getAcceptProcessInitiationTime, getStartAcceptTime} from '@/api/acceptanceManagement/acceptanceMange'
export default {
  components: {
    accButton,
    TForm
  },
  mixins: [Mixins],
  data() {
    return {
      firstAcceptTime:"",
      formList: ['realStartTime', 'realEndTime', 'endInternalAcceptDate', 'jiaofuApplicationDate', 'endInstallDate', 'endInstallDate2', 'resourceInTime', 'resourceConfirmTime', 'maintainDate']
    }
  },
  computed: {
    // 研发项目
    getYanFa() {
     return this.newPrjDetail.manageMode === '01' && this.newPrjDetail.prjType === 'Y'
    },
    isReplace() {
      return this.newPrjDetail.buildModes === '07'
    },
    // 单站智联项目
    getShowOne() {
      return this.newPrjDetail.manageMode === '01' && this.newPrjDetail.isNewBusiness === '1'
    },
    // 维护改造
    getShowOneNew(){
      return this.newPrjDetail.isNewBusiness === '0'&&this.newPrjDetail.businessMajor==='04'
    },
    // 服务成本 设备录入
    getShowTwo() {
      return this.newPrjDetail.buildModes === '26' && this.newPrjDetail.prjType === 'W'
    },
    // 软件开发 服务成本
    getShowThree() {
      return this.newPrjDetail.manageMode === '01' && this.newPrjDetail.prjType === 'W' && this.newPrjDetail.buildModes === '25' && this.newPrjDetail.isSingleAccounting === '1'
    },
    btnList() {
      // 代建类项目服务成本类不显示乙供物资明细配置
      let showThrees = []
      if (this.getShowTwo) {
        showThrees = ['panorama']
      } else if (this.isReplace) {
        showThrees = ['costSheet', 'threeOrders', 'panorama']
      } else {
        showThrees =this.newPrjDetail.ifNewStartupProcess==='1'&&this.newPrjDetail.isMaintain==='0'?['serviceEdit', 'costSheet', 'threeOrders', 'panorama']:['serviceShow', 'costSheet', 'threeOrders', 'panorama']
      }
      if (this.getYanFa) {
        return ['serviceShow', 'panorama']
      }
      if (this.isReplace) {
        return ['costSheet', 'threeOrders', 'panorama']
      } else if ((this.getShowOne)||this.getShowOneNew) {
        return showThrees
      } else {
        return ['serviceShow', 'costSheet', 'threeOrders', 'panorama', 'supervisor']
      }
    }
  },
  created(){
    this.formList = this.getYanFa || this.getShowThree?['endInternalAcceptDate']:this.formList
    // 研发
    if(this.getYanFa){
      this.getEndTime()
    }
    // 软件开发、服务成本
    if(this.getShowThree){
      this.getStartTime()
    }
  },
  methods:{
    async getEndTime() {
      this.$nextTick(() => {
        this.$refs.myTitle.style.display = 'none'
       })
      const {code,data} = await getAcceptProcessInitiationTime({ prjId: this.prjId })
      if(+code===200){
        this.firstAcceptTime=data
      }
    },
    async getStartTime() {
      this.$nextTick(() => {
        this.$refs.myTitle.style.display = 'none'
      })
      const {code,data} = await getStartAcceptTime({ prjId: this.prjId })
      if(+code===200){
        this.firstAcceptTime=data
      }
    },
  },
}
</script>
<style scoped lang='scss'></style>
